import{getgdcomment, getgedanmusic,loginaccount,getmusiclist,getsongslist,getzhuanji, getsongsmv, getsongsdsc, getlikesongs} from '@/api'
const state = {
    gedandetail:[],
    getuser:[],
    getcomment:[],
    getmusiclist:[],
    getsongslist:{},
    getzhuanji:{},
    getsongsmv:[],
    getsongsdsc:{},
    getlikesongs:[]
}
const mutations={
    GETGEDANMUSIC(state,res){
        state.gedandetail=JSON.parse(JSON.stringify(res))
        //console.log(state.gedandetail);
    },
    LOGUSER(state,res){
        state.getuser=JSON.parse(JSON.stringify(res.profile))
        //console.log(  state.getuser);
    },
    GETCOMMENT(state,res){
        state.getcomment=JSON.parse(JSON.stringify(res))
        //console.log(state.getcomment);
    },
    GETMUSICLIST(state,res){
        state.getmusiclist=JSON.parse(JSON.stringify(res))
        console.log(state.getmusiclist);
    },
    GETSONGSLIST(state,res){
      state.getsongslist=JSON.parse(JSON.stringify(res.data))
    },
    GETZHUANJI(state,res){
        state.getzhuanji=JSON.parse(JSON.stringify(res.hotAlbums))
       // console.log(state.getzhuanji);
    },
    GETSONGSMV(state,res){
        state.getsongsmv=JSON.parse(JSON.stringify(res))
    },
    GETSONGSDSC(state,res){
        state.getsongsdsc=JSON.parse(JSON.stringify(res))
    },
    GETLIKESONGS(state,res){
        state.getlikesongs=JSON.parse(JSON.stringify(res))
    }
}
const actions={
   //获取歌单音乐
    async getgedanmusic({commit},m){
            const res =await getgedanmusic(m);
            console.log(res);
            if(res.code==200){
                commit('GETGEDANMUSIC',res)
            }
    },
    //获取评论
    async getgdcomment({commit},m){
        const res = await getgdcomment(m);
        //console.log(res);
        if(res.code==200){
            commit('GETCOMMENT',res)
        }
    },
    //获取用户信息
    async loginaccount({commit}){
   const res =await loginaccount();
  // console.log(res);
      if(res.code==200){
          commit('LOGUSER',res)
      }
    },
    //获取歌曲详情
    async getmusiclist ({commit},ids){
        const res =await getmusiclist(ids);
        //console.log(res);
        if(res.code=200){
            commit('GETMUSICLIST',res.songs)
        }
    },
    //获取歌手详情
    async getsongslist({commit},id){
        const res = await getsongslist(id);
        console.log(res);
        if(res.code=200){
            commit('GETSONGSLIST',res)
         }
    },
    //获取专辑
    async getzhuanji({commit},{m,mi}){
        
   const res =await getzhuanji(m,mi);
   console.log(res);
   if(res.code=200){
    commit('GETZHUANJI',res)
 }
    },
    //获取歌手mv
    async getsongsmv({commit},{m,mi}){
         const res =await getsongsmv(m,mi)
         console.log(res);
       if(res.code=200){
           commit('GETSONGSMV',res.mvs)
       }
    },
    //获取歌手描述
    async getsongsdsc({commit},m){
       const res = await getsongsdsc(m)
       console.log(res);
      if(res.code=200){
        commit('GETSONGSDSC',res)
        }
    },
    //获取相似歌手
    async getlikesongs({commit},m){
        const res =await getlikesongs(m);
        console.log(res);
        if(res.code=200){
            commit('GETLIKESONGS',res.artists)
        }
    },
    
    
}
const getters={}
export default {
    state,
    mutations,
    actions,
    getters
 }